package com.ding.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;

import com.ding.pojo.User;

@Configuration
public class RedisConfig {

	@Primary
	@Bean
	public RedisTemplate<String, User> userRedisTemplate(RedisConnectionFactory factory) {
		RedisTemplate<String,User> redis = new RedisTemplate<>();
		redis.setConnectionFactory(factory);
		redis.setValueSerializer(new GenericJackson2JsonRedisSerializer());
		return redis;
	}
}
